package com.xsq.util;

import java.text.DecimalFormat;

public class StringFormatUtils {

	public static  String getFormatJe(String je){
		DecimalFormat myformat = new DecimalFormat();
		myformat.applyPattern("##,###.00");
		String s = myformat.format(Double.parseDouble(je));
		if(s.startsWith(".")){
			s = "0"+s;
		}
		StringBuffer buf = new StringBuffer();
		if(s.length()<12){
			for(int i=0;i<12-s.length();i++){
				buf.append(" ");
			}
			s = buf.toString()+s;
		}
		return s;
	}
	
	public static  String getFormatJe(String je,int length){
		DecimalFormat myformat = new DecimalFormat();
		myformat.applyPattern("##,###.00");
		String s = myformat.format(Double.parseDouble(je));
		if(s.startsWith(".")){
			s = "0"+s;
		}
		StringBuffer buf = new StringBuffer();
		if(s.length()<length){
			for(int i=0;i<length-s.length();i++){
				buf.append(" ");
			}
			s = buf.toString()+s;
		}
		return s;
	}
	
	
	public static  String getFormatLX(String s){
		
		StringBuffer buf = new StringBuffer();
		if(s.length()<4){
			for(int i=0;i<4-s.length();i++){
				buf.append(" ");
			}
			s = buf.toString()+s;
		}
		return s;
	}
	
	public static  String getFormatRc(String s){
		
		StringBuffer buf = new StringBuffer();
		if(s.length()<9){
			for(int i=0;i<9-s.length();i++){
				buf.append(" ");
			}
			s = buf.toString()+s;
		}
		return s;
	}
	
}
